// 引入路由
const koaRouter = require('koa-router');
// 实例化路由
const router = new koaRouter();

// 自定义中间件
const ifyUser = require('../middleware/verifyUser')

const v = '/api/v1'

// 商品
const Good = require('../controllers/webapp/home')
// 商品分类
const Cate = require('../controllers/webapp/cate')
// 用户
const User = require('../controllers/webapp/user')
// 购物车
const Carts = require('../controllers/webapp/carts')

router
  .get(`${v}/goods`, Good.getGoods)//首页商品
  .get(`${v}/goods/details`, Good.getGoodsDetails)//商品详情
  .get(`${v}/cates`, Cate.getCates)//商品分类
  .post(`${v}/users/insert`, User.addUser)//添加用户
  .post(`${v}/users/login`, User.loginUser)//用户登录
  .get(`${v}/carts`, ifyUser, Carts.getCartsGood)//查询购物车
  .post(`${v}/carts/insert`, ifyUser, Carts.addCartsGood)//添加购物车
  .post(`${v}/carts/update`, ifyUser, Carts.updateCartsGood)//修改购物车
  .post(`${v}/carts/delete`, ifyUser, Carts.deletCartsGood)//删除购物车商品


module.exports = router